import Page
from Page import Yomi
from Base.Base import Base
from selenium.webdriver.common.by import By


class YomiIndexPage(Base):
    """
    语音训练首页

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.yomi_home_btn = (By.XPATH, Yomi.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.yomi_back_btn = (By.XPATH, Yomi.RESOURCE_ID.format('ivBack'))

        # yomi标题
        self.yomi_title_text = (By.XPATH, Yomi.RESOURCE_ID.format("tv_title"))

        # yomi图片
        self.yomi_cover_img = (By.XPATH, Yomi.RESOURCE_ID.format("iv_empty"))

        # yomi文案提示
        self.yomi_tip_text = (By.XPATH, Yomi.RESOURCE_ID.format("tv_empty"))

        # yomi创建按钮
        self.yomi_create_btn = (By.XPATH, Yomi.RESOURCE_ID.format("btn_create_skill"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.yomi_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.yomi_back_btn)

    def get_title(self):
        """
        获取yomi标题

        :return:获取元素
        """
        return self.find_element_o(self.yomi_title_text)

    def get_cover(self):
        """
        获取yomi图片

        :return:获取元素
        """
        return self.find_element_o(self.yomi_cover_img)

    def get_tip(self):
        """
        获取yomi文案

        :return:获取元素
        """
        return self.find_element_o(self.yomi_tip_text)

    def click_create(self):
        """
        点击创建按钮

        :return:None
        """
        self.click_element(self.yomi_create_btn)

    def is_display_yomi_index(self):
        """
        查看是否进入语音训练首页

        :return:
        """
        return self.is_display(self.yomi_create_btn)
